import java.util.Arrays;
import java.util.Scanner;
class main_977 {

    public int[] sortedSquares(int[] nums) {
        int[] ans = new int[nums.length];
        for (int i = 0; i < nums.length; i++) {
            ans[i] = nums[i] * nums[i];
        }
        Arrays.sort(ans);
        return ans;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Solution_977 solution = new Solution_977();

        System.out.println("请输入数组的元素 ");
        String line = scanner.nextLine();
        String[] elements = line.split("\\s+");
        int[] nums = new int[elements.length];
        for (int i = 0; i < elements.length; i++) {
            nums[i] = Integer.parseInt(elements[i]);
        }

        int[] result = solution.sortedSquares(nums);
        System.out.println("排序后的平方数组: " + Arrays.toString(result));

        scanner.close();
    }
}



